package com.ch.databinddemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import com.ch.databinddemo.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val activity: ActivityMainBinding =
            DataBindingUtil.setContentView(this, R.layout.activity_main)
        val idol = Idol(
            "陈虎123",
            5,
            "https://www.wanandroid.com/blogimgs/62c1bd68-b5f3-4a3c-a649-7ca8c7dfabe6.png"
        )
        activity.idol = idol
        activity.eventHandler = EventHandlerListener(this)
        val myViewModel = ViewModelProviders.of(this).get(MyViewModel::class.java)
        activity.viewModel = myViewModel
        activity.lifecycleOwner = this


    }
}